<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>02 window常用的事件.html</title>
    <style>
        body {
            height: 3000px;
        }
    </style>
</head>

<body onunload="alert('the onunload event was triggered')">
    <script>
        // onload 如果有多个，会覆盖，只会执行最后一个
        window.onload = function() {
            console.log('111');
        }
        window.onload = function() {
            console.log('222');
        }
        window.onload = function() {
            console.log('333');
        }

        window.onunload = function() {
            alert('0000');
        }
        window.onbeforeunload = function() {
            alert('before');
        }

        window.onscroll = function() {
            console.log('滚滚');
        }

        window.onresize = function() {
            console.log('大小变了');
        }

        // onerror事件   错误的时候触发
        function onerr() {
            console.log('图片加载出错');
        }
    </script>
</body>

</html>